home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / dev / e / yaec.lha / examples / hooks1.e < prev    next >
Text File  |  2001-08-12  |  1KB  |  45 lines

  1. -> hooks1.e
  2.  
  3. ->>> Header (globals)
  4.  
  5. MODULE '*ecode_lnk'
  6.  
  7. MODULE 'utility/hooks'
  8.  
  9. MODULE 'utility'
  10.  
  11. ENUM ERR_NONE, ERR_LIB, ERR_HOOK
  12.  
  13. RAISE ERR_LIB IF OpenLibrary()=NIL
  14. ->>>
  15.  
  16. ->>> PROC myFunction(h:PTR TO hook, o, msg)
  17. -> This function only prints out a message indicating that we are inside the
  18. -> callback function.
  19. PROC myFunction(h:PTR TO hook, o, msg)
  20.   -> E-Note: installhook has set-up access to data segment
  21.   WriteF('Inside myFunction()\n')
  22. ENDPROC 1
  23. ->>>
  24.  
  25. ->>> PROC main()
  26. PROC main() HANDLE
  27.   DEF h:PTR TO hook
  28.   -> Open the utility library
  29.   utilitybase:=OpenLibrary('utility.library', 36)
  30.   -> Initialise the callback hook
  31.   -> E-Note: use installhook to do the main stuff (so h.data cannot be used)
  32.   IF (h := ECodeUtilHook({myFunction}, NIL)) = NIL THEN Raise(ERR_HOOK)
  33.   -> Use the utility library function to invoke the hook
  34.  CallHookPkt(h, NIL, NIL)
  35.  
  36. EXCEPT DO
  37.   IF utilitybase THEN CloseLibrary(utilitybase)
  38.   SELECT exception
  39.   CASE ERR_LIB;  WriteF('Error: could not open utility library\n')
  40.   CASE ERR_HOOK;   WriteF('Error: could not install hook\n')
  41.   ENDSELECT
  42. ENDPROC
  43. ->>>
  44.  
  45.